<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <style type="text/css">

        /* tooltip */
        #tooltip{
            position:absolute;
            border:1px solid #ccc;
            background:#333;
            padding:2px;
            display:none;
            color:#fff;
        }
    </style>
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    <button class="layui-btn layui-btn-sm adds">添加版本</button>
    <table class="layui-table" lay-size="sm">
        <colgroup>
            <col width="50">
            <col width="300">
            <col width="50">
            <col width="100">
            <col width="100">
            <col width="150">
            <col width="100">
            <col width="150">
            <col width="50">
            <col width="50">
            <col width="100">
        </colgroup>
        <thead>
        <tr>
            <th>版本号</th>
            <th>版本说明</th>
            <th>强制更新</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="shuju" id="vo"}
        <tr>
            <td>{$vo.appversion}</td>
            <td>{$vo.version_release}</td>
            <td>{$vo.mandatorys}</td>
            <td class="operation-menu">
                <div class="layui-btn-group">
                    <a href="javascript:;" class="layui-btn layui-btn-xs a_menu layui-btn-primary editer" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
                    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
                </div>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>

    {include file="public/foot"}
    <script type="text/javascript">

        $('.adds').click(function(){
            var id = '{$usid}';
            layer.open({
                type: 2
                ,content: "{:url('admin/app_system/vsadd')}?id=" + id
                ,shadeClose: true
                ,area: ['90%', '90%']
                ,maxmin: true
                ,title:'添加版本'
            });
        })

        $('.delete').click(function(){
            var id = $(this).attr('id');
            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/app_system/verdelete')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.href = res.url;
                            },1500)
                        }
                    }
                })
            })
        })

        $('.editer').click(function(){
            var id = $(this).attr('id');
            layer.open({
                type: 2
                ,content: "{:url('admin/app_system/ediviosn')}?id=" + id
                ,shadeClose: true
                ,area: ['90%', '90%']
                ,maxmin: true
                ,title:'版本管理'
            });
        })
    </script>
    <script type="text/javascript">

        $('.is_top').click(function(){
            var val = $(this).attr('data-val');
            var id = $(this).attr('data-id');
            var i = $(this).find('i');
            var the = $(this);
            if(val == 1){
                var is_top = 0;
            } else {
                var is_top = 1;
            }
            $.ajax({
                type:"post",
                url:"{:url('admin/article/is_top')}",
                data:{is_top:is_top,id:id},
                success:function(res){

                    if(res.code == 1) {
                        top();
                    } else {
                        layer.msg(res.msg);
                    }
                }
            })

            function top(){
                if(val == 1){
                    i.attr("class","fa fa-toggle-off");
                    the.attr('data-val',0);
                } else {
                    i.attr("class","fa fa-toggle-on");
                    the.attr('data-val',1);
                }
            }
        })


        $('.status').click(function(){
            var val = $(this).attr('data-val');
            var id = $(this).attr('data-id');
            var i = $(this).find('i');
            var the = $(this);
            if(val == 1){
                var status = 0;
            } else {
                var status = 1;
            }
            $.ajax({
                type:"post",
                url:"{:url('admin/article/status')}",
                data:{status:status,id:id},
                success:function(res){

                    if(res.code == 1) {
                        tostatus();
                    } else {
                        layer.msg(res.msg);
                    }
                }
            })

            function tostatus(){
                if(val == 1){
                    i.attr("class","fa fa-toggle-off");
                    the.attr('data-val',0);
                } else {
                    i.attr("class","fa fa-toggle-on");
                    the.attr('data-val',1);
                }
            }
        })
    </script>
</div>
</body>
</html>
